# Maintainer: Michael Hansen <zrax0111 gmail com>

_realname=capstone
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-capstone")
_pkgver=3.0.5-rc3
pkgver=${_pkgver//-/}
pkgrel=1
pkgdesc='A lightweight multi-platform, multi-architecture disassembly framework'
url='http://www.capstone-engine.org/index.html'
arch=('any')
license=('BSD')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-cmake")
source=("${_realname}-${_pkgver}.tar.gz::https://github.com/aquynh/capstone/archive/${_pkgver}.tar.gz")
sha512sums=('1327fc570fc2310f71c4d7329528c05e30b9ad68ea50254b9a8c4b3b113f5165c2e0474ec99bbe1e6e46f2820379f388e4c2082c156027e117d88a8f1908acfe')

build() {
  mkdir -p build-${MINGW_CHOST}
  cd build-${MINGW_CHOST}

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake \
    -G"MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX="${MINGW_PREFIX}" \
    -DCMAKE_BUILD_TYPE=Release \
    ../${_realname}-${_pkgver}

  make
}

package() {
  cd build-${MINGW_CHOST}

  make DESTDIR="${pkgdir}" install
  install -Dm644 "${srcdir}/${_realname}-${_pkgver}/LICENSE.TXT" "${pkgdir}/${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
